package com.zkingsoft.actions.admin;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zkingsoft.actions.common.BaseController;
import com.zkingsoft.anotations.RemoveRequestToken;
import com.zkingsoft.anotations.SaveRequestToken;
import com.zkingsoft.model.AnswerProperty;
import com.zkingsoft.model.NewAssessment;
import com.zkingsoft.model.TaskExecution;
import com.zkingsoft.plugin.pojo.PaginationVO;
import com.zkingsoft.plugin.util.WebUtil;
import com.zkingsoft.pojo.AjaxResult;
import com.zkingsoft.services.NewAssessmentService;
import com.zkingsoft.services.TaskExecutionService;

/**
 * This field was generated by Zking.software.Codegen.
 * @date 2016-12-07 11:38
 */
@Controller
@RequestMapping(value = "admin/taskExecution")
public class TaskExecutionController extends BaseController{

	@Resource
	private TaskExecutionService currentService;
	@Resource
	private NewAssessmentService newAssessmentService;
	
	/**
	 * �б���ʾ
	 */
	@RequestMapping(value = "/showList")
	public @ResponseBody AjaxResult showList(TaskExecution taskExecution, PaginationVO pageVo) {
		return showList(currentService, taskExecution, pageVo);
	}
   	
	/**
	 * ���������޸�ҳ��
	 */   
	@RemoveRequestToken	
   	@RequestMapping(value = "/addOrModify")
	public @ResponseBody AjaxResult addOrModify(TaskExecution taskExecution) {
		if (taskExecution.getId() != null) {
			return modify(currentService, taskExecution, "taskExecution");
		} else {
			return add(currentService, taskExecution, "taskExecution");
		}
	}
	
   	/**
	 * �����޸Ľ���
	 */   
	@SaveRequestToken
   	@RequestMapping(value = "/editForm")
	public String editForm(Long id) {
		TaskExecution taskExecution;
		if (id != null) {
			taskExecution = currentService.findById(id);
			WebUtil.getRequest().setAttribute("obj", taskExecution);
		}
		return "admin/taskExecution-form";
	}
   	
   	
   	/**
	 * ɾ��
	 */  
 	@RequestMapping(value = "/del")
	public @ResponseBody AjaxResult del(String keys) {
		return remove(currentService, keys);
	}
  /**
   * 查询当前用户完成的任务
   */
 	@RequestMapping(value = "/showUserTask")
	public @ResponseBody AjaxResult showUserTask(TaskExecution taskExecution,HttpServletRequest request) {
 		NewAssessment newAssessment = new NewAssessment();
		newAssessment.setNewId(getMe().getId());
		List<NewAssessment>	newAssessmentList = newAssessmentService.findByModel(newAssessment);
		Map<Object, Object> map=new HashMap<Object, Object>();
		if(newAssessmentList.size()>0){
			map.put("newAssessment", newAssessmentList.get(0));
		}else{
			map.put("newAssessment", newAssessment);
		}
 		taskExecution.setNewId(getMe().getId());
		taskExecution.setStatus("2");
		List<TaskExecution> taskExecutionList = currentService.findByModel(taskExecution);
		AjaxResult mapResult;
		if(taskExecutionList.size()<=0){
			mapResult= new AjaxResult(AjaxResult.STATUS_OK, null, "新手任务开始");
		    mapResult.setMapInfo(map);
			return mapResult;
		}
		mapResult = new AjaxResult(AjaxResult.STATUS_OK, null, "新手任务完成中",taskExecutionList,taskExecutionList.size()); 
		mapResult.setMapInfo(map);
		return mapResult; 
	}
 	
 	/**
 	 * 比对新手必读任务问题答案
 	 */
 	@RequestMapping(value = "/comparisonQuestion1Answer")
	public @ResponseBody AjaxResult comparisonQuestion1Answer(AnswerProperty answerProperty) {
 		//判断是否答题
 		if("".equals(answerProperty.getAnswer1())||answerProperty.getAnswer1()==null||"".equals(answerProperty.getAnswer2())||answerProperty.getAnswer2()==null
 		||"".equals(answerProperty.getAnswer3())||answerProperty.getAnswer3()==null||"".equals(answerProperty.getAnswer4())||answerProperty.getAnswer4()==null
 		||"".equals(answerProperty.getAnswer5())||answerProperty.getAnswer5()==null||"".equals(answerProperty.getAnswer6())||answerProperty.getAnswer6()==null
 		||"".equals(answerProperty.getAnswer7())||answerProperty.getAnswer7()==null||"".equals(answerProperty.getAnswer8())||answerProperty.getAnswer8()==null
 		||"".equals(answerProperty.getAnswer9())||answerProperty.getAnswer9()==null||"".equals(answerProperty.getAnswer10())||answerProperty.getAnswer10()==null
 		){
 			return new AjaxResult(AjaxResult.STATUS_ERR, null, "还有问题未填写答案哦！");
 		}
 		List<String> list = new ArrayList<String>();
 		list.add("b");
 		list.add("c");
 		list.add("a");
 		list.add("b");
 		list.add("b");
 		list.add("a");
 		list.add("c");
 		list.add("c");
 		list.add("a");
 		list.add("b");
		if(answerProperty.getAnswer1().equals(list.get(0))&&answerProperty.getAnswer2().equals(list.get(1))
		&&answerProperty.getAnswer3().equals(list.get(2))&&answerProperty.getAnswer4().equals(list.get(3))
		&&answerProperty.getAnswer5().equals(list.get(4))&&answerProperty.getAnswer6().equals(list.get(5))
		&&answerProperty.getAnswer7().equals(list.get(6))&&answerProperty.getAnswer8().equals(list.get(7))
		&&answerProperty.getAnswer9().equals(list.get(8))&&answerProperty.getAnswer10().equals(list.get(9))
			){
			TaskExecution taskExecution = new TaskExecution();
			taskExecution.setNewId(getMe().getId());
			taskExecution.setStatus("2");
			taskExecution.setTaskName("新手必读");
			currentService.add(taskExecution);
			return new AjaxResult(AjaxResult.STATUS_OK, null, "新手必读任务问题全部回答正确");
		}
		return new AjaxResult(AjaxResult.STATUS_ERR, null, "有回答错误的答案，请重新阅读再回答问题！");
 	}
 	
 	/**
 	 * 比对开发规范任务问题答案
 	 */
 	@RequestMapping(value = "/comparisonQuestion2Answer")
	public @ResponseBody AjaxResult comparisonQuestion2Answer(AnswerProperty answerProperty) {
 		//判断是否答题
 		if("".equals(answerProperty.getAnswer1())||answerProperty.getAnswer1()==null||"".equals(answerProperty.getAnswer2())||answerProperty.getAnswer2()==null
 			||"".equals(answerProperty.getAnswer3())||answerProperty.getAnswer3()==null){
 			return new AjaxResult(AjaxResult.STATUS_ERR, null, "还有问题未填写答案哦！");
 		}
 		List<String> list = new ArrayList<String>();
 		list.add("d");
 		list.add("c");
 		list.add("b");
		if(answerProperty.getAnswer1().equals(list.get(0))&&answerProperty.getAnswer2().equals(list.get(1))
				&&answerProperty.getAnswer3().equals(list.get(2))){
			TaskExecution taskExecution = new TaskExecution();
			taskExecution.setNewId(getMe().getId());
			taskExecution.setStatus("2");
			taskExecution.setTaskName("开发规范");
			currentService.add(taskExecution);
			return new AjaxResult(AjaxResult.STATUS_OK, null, "开发规范任务问题全部回答正确");
		}
		return new AjaxResult(AjaxResult.STATUS_ERR, null, "有回答错误的答案，请重新阅读再回答问题！");
 	}
 	/**
 	 * 新人开始框架教学任务
 	 */
 	@RequestMapping(value="/startTask")
 	public @ResponseBody AjaxResult startTask(TaskExecution taskExecution){
 		taskExecution.setNewId(getMe().getId());
 		taskExecution.setStatus("1");
 		taskExecution.setTaskName("框架教学");
 		List<TaskExecution> taskExecutionList = currentService.findByModel(taskExecution);
 		if(taskExecutionList.size()>0){
 			return new AjaxResult(AjaxResult.STATUS_ERR, null, "框架教学已经开始啦~不要在点啦");
 		}
 		int i = currentService.add(taskExecution);
 		if(i>0){
 			return new AjaxResult(AjaxResult.STATUS_OK, null, "框架教学已开始");
 		}
 		return new AjaxResult(AjaxResult.STATUS_ERR, null, "操作失败！");
 	}
 	
 	/**
 	 * 导师结束框架教学任务
 	 */
 	@RequestMapping(value="/endTask")
 	public @ResponseBody AjaxResult endTask(TaskExecution taskExecution,Long key){
 		NewAssessment newAssessment = newAssessmentService.findById(key);
 		taskExecution.setNewId(newAssessment.getNewId());
 		taskExecution.setTaskName("框架教学");
 		List<TaskExecution> taskExecutionList = currentService.findByModel(taskExecution);
 		if(taskExecutionList.size()<=0){
 			 return new AjaxResult(AjaxResult.STATUS_ERR, null, "学员还未开始本任务哦！");
 		}
 		if(taskExecutionList.get(0).getStatus().equals("2")){
 			return new AjaxResult(AjaxResult.STATUS_ERR, null, "学员已经完成本任务了哦~");
 		}
 		TaskExecution taskExecution1 = taskExecutionList.get(0);
 		taskExecution1.setStatus("2");
 		int i = currentService.modify(taskExecution1);
 		if(i>0){
 			return new AjaxResult(AjaxResult.STATUS_OK, null, "框架教学已结束");
 		}
 		return new AjaxResult(AjaxResult.STATUS_ERR, null, "操作失败！");
 	}
 	
 	/**
 	 * 查看学生学习视频到哪个
 	 */
 	@RequestMapping(value="/studentVideo")
 	public @ResponseBody AjaxResult studentVideo(){
 		TaskExecution taskExecution = new TaskExecution();
		taskExecution.setNewId(getMe().getId());
		taskExecution.setTaskName("视频学习");
		List<TaskExecution> taskExecutionList = currentService.findByModel(taskExecution);
		if(taskExecutionList.size()>0){
			return new AjaxResult(AjaxResult.STATUS_OK, null, "视频学习已开始", taskExecutionList, 1);
		}
		return new AjaxResult(AjaxResult.STATUS_OK, null, "暂未开始视频学习");
 	}
 	/**
 	 * 比对视频学习任务1问题答案
 	 */
 	@RequestMapping(value = "/comparisonQuestion3Answer")
	public @ResponseBody AjaxResult comparisonQuestion3Answer(AnswerProperty answerProperty) {
 		//判断是否答题
 		if("".equals(answerProperty.getAnswer1())||answerProperty.getAnswer1()==null||"".equals(answerProperty.getAnswer2())||answerProperty.getAnswer2()==null){
 			return new AjaxResult(AjaxResult.STATUS_ERR, null, "还有问题未填写答案哦！");
 		}
 		List<String> list = new ArrayList<String>();
 		list.add("c");
 		list.add("d");
		if(answerProperty.getAnswer1().equals(list.get(0))&&answerProperty.getAnswer2().equals(list.get(1))){
			TaskExecution taskExecution = new TaskExecution();
			taskExecution.setNewId(getMe().getId());
			taskExecution.setTaskName("视频学习");
			List<TaskExecution> taskExecutionList = currentService.findByModel(taskExecution);
			if(taskExecutionList.size()<=0){
				taskExecution.setStatus("3");
				currentService.add(taskExecution);
			}else{
				int i = Integer.parseInt(taskExecutionList.get(0).getStatus());
				if(i==5){
					taskExecutionList.get(0).setStatus("2");
				}else{
					taskExecutionList.get(0).setStatus((i+1)+"");
				}
				currentService.modify(taskExecutionList.get(0));
			}
			return new AjaxResult(AjaxResult.STATUS_OK, null, "视频学习任务1问题全部回答正确");
		}
		return new AjaxResult(AjaxResult.STATUS_ERR, null, "有回答错误的答案，请重新阅读再回答问题！");
 	}
 	
 	/**
 	 * 比对视频学习任务2问题答案
 	 */
 	@RequestMapping(value = "/comparisonQuestion4Answer")
	public @ResponseBody AjaxResult comparisonQuestion4Answer(AnswerProperty answerProperty) {
 		//判断是否答题
 		if("".equals(answerProperty.getAnswer1())||answerProperty.getAnswer1()==null||"".equals(answerProperty.getAnswer2())||answerProperty.getAnswer2()==null
 		||"".equals(answerProperty.getAnswer3())||answerProperty.getAnswer3()==null){
 			return new AjaxResult(AjaxResult.STATUS_ERR, null, "还有问题未填写答案哦！");
 		}
 		List<String> list = new ArrayList<String>();
 		list.add("d");
 		list.add("d");
 		list.add("b");
		if(answerProperty.getAnswer1().equals(list.get(0))&&answerProperty.getAnswer2().equals(list.get(1))
				&&answerProperty.getAnswer3().equals(list.get(2))){
			TaskExecution taskExecution = new TaskExecution();
			taskExecution.setNewId(getMe().getId());
			taskExecution.setTaskName("视频学习");
			List<TaskExecution> taskExecutionList = currentService.findByModel(taskExecution);
			if(taskExecutionList.size()<=0){
				taskExecution.setStatus("3");
				currentService.add(taskExecution);
			}else{
				int i = Integer.parseInt(taskExecutionList.get(0).getStatus());
				if(i==5){
					taskExecutionList.get(0).setStatus("2");
				}else{
					taskExecutionList.get(0).setStatus((i+1)+"");
				}
				currentService.modify(taskExecutionList.get(0));
			}
			return new AjaxResult(AjaxResult.STATUS_OK, null, "视频学习任务2问题全部回答正确");
		}
		return new AjaxResult(AjaxResult.STATUS_ERR, null, "有回答错误的答案，请重新阅读再回答问题！");
 	}
 	
 	/**
 	 * 比对视频学习任务3问题答案
 	 */
 	@RequestMapping(value = "/comparisonQuestion5Answer")
	public @ResponseBody AjaxResult comparisonQuestion5Answer(AnswerProperty answerProperty) {
 		//判断是否答题
 		if("".equals(answerProperty.getAnswer1())||answerProperty.getAnswer1()==null||"".equals(answerProperty.getAnswer2())||answerProperty.getAnswer2()==null
 		||"".equals(answerProperty.getAnswer3())||answerProperty.getAnswer3()==null){
 			return new AjaxResult(AjaxResult.STATUS_ERR, null, "还有问题未填写答案哦！");
 		}
 		List<String> list = new ArrayList<String>();
 		list.add("c");
 		list.add("c");
 		list.add("b");
 		if(answerProperty.getAnswer1().equals(list.get(0))&&answerProperty.getAnswer2().equals(list.get(1))
				&&answerProperty.getAnswer3().equals(list.get(2))){
			TaskExecution taskExecution = new TaskExecution();
			taskExecution.setNewId(getMe().getId());
			taskExecution.setTaskName("视频学习");
			List<TaskExecution> taskExecutionList = currentService.findByModel(taskExecution);
			if(taskExecutionList.size()<=0){
				taskExecution.setStatus("3");
				currentService.add(taskExecution);
			}else{
				int i = Integer.parseInt(taskExecutionList.get(0).getStatus());
				if(i==5){
					taskExecutionList.get(0).setStatus("2");
				}else{
					taskExecutionList.get(0).setStatus((i+1)+"");
				}
				currentService.modify(taskExecutionList.get(0));
			}
			return new AjaxResult(AjaxResult.STATUS_OK, null, "视频学习任务3问题全部回答正确");
		}
		return new AjaxResult(AjaxResult.STATUS_ERR, null, "有回答错误的答案，请重新阅读再回答问题！");
 	}
 	
 	/**
 	 * 比对视频学习任务4问题答案
 	 */
 	@RequestMapping(value = "/comparisonQuestion6Answer")
	public @ResponseBody AjaxResult comparisonQuestion6Answer(AnswerProperty answerProperty) {
 		//判断是否答题
 		if("".equals(answerProperty.getAnswer1())||answerProperty.getAnswer1()==null||"".equals(answerProperty.getAnswer2())||answerProperty.getAnswer2()==null
 		||"".equals(answerProperty.getAnswer3())||answerProperty.getAnswer3()==null){
 			return new AjaxResult(AjaxResult.STATUS_ERR, null, "还有问题未填写答案哦！");
 		}
 		List<String> list = new ArrayList<String>();
 		list.add("c");
 		list.add("a");
 		list.add("d");
 		if(answerProperty.getAnswer1().equals(list.get(0))&&answerProperty.getAnswer2().equals(list.get(1))
				&&answerProperty.getAnswer3().equals(list.get(2))){
			TaskExecution taskExecution = new TaskExecution();
			taskExecution.setNewId(getMe().getId());
			taskExecution.setTaskName("视频学习");
			List<TaskExecution> taskExecutionList = currentService.findByModel(taskExecution);
			if(taskExecutionList.size()<=0){
				taskExecution.setStatus("3");
				currentService.add(taskExecution);
			}else{
				int i = Integer.parseInt(taskExecutionList.get(0).getStatus());
				if(i==5){
					taskExecutionList.get(0).setStatus("2");
				}else{
					taskExecutionList.get(0).setStatus((i+1)+"");
				}
				currentService.modify(taskExecutionList.get(0));
			}
			return new AjaxResult(AjaxResult.STATUS_OK, null, "视频学习任务4问题全部回答正确");
		}
		return new AjaxResult(AjaxResult.STATUS_ERR, null, "有回答错误的答案，请重新阅读再回答问题！");
 	}
 	
 	
 	/**
 	 * 新人开始撰写周报任务
 	 */
 	@RequestMapping(value="/startWeeklyTask")
 	public @ResponseBody AjaxResult startWeeklyTask(TaskExecution taskExecution){
 		taskExecution.setNewId(getMe().getId());
 		taskExecution.setStatus("1");
 		taskExecution.setTaskName("撰写周报");
 		List<TaskExecution> taskExecutionList = currentService.findByModel(taskExecution);
 		if(taskExecutionList.size()>0){
 			return new AjaxResult(AjaxResult.STATUS_ERR, null, "撰写周报已经开始啦~不要在点啦");
 		}
 		int i = currentService.add(taskExecution);
 		if(i>0){
 			return new AjaxResult(AjaxResult.STATUS_OK, null, "撰写周报已开始");
 		}
 		return new AjaxResult(AjaxResult.STATUS_ERR, null, "操作失败！");
 	}
 	
 	/**
 	 * 导师结束撰写周报任务
 	 */
 	@RequestMapping(value="/endWeeklyTask")
 	public @ResponseBody AjaxResult endWeeklyTask(TaskExecution taskExecution,Long key){
 		NewAssessment newAssessment = newAssessmentService.findById(key);
 		taskExecution.setNewId(newAssessment.getNewId());
 		taskExecution.setTaskName("撰写周报");
 		List<TaskExecution> taskExecutionList = currentService.findByModel(taskExecution);
 		if(taskExecutionList.size()<=0){
 			 return new AjaxResult(AjaxResult.STATUS_ERR, null, "学员还未开始本任务哦！");
 		}
 		if(taskExecutionList.get(0).getStatus().equals("2")){
 			return new AjaxResult(AjaxResult.STATUS_ERR, null, "学员已经完成本任务了哦~");
 		}
 		TaskExecution taskExecution1 = taskExecutionList.get(0);
 		taskExecution1.setStatus("2");
 		int i = currentService.modify(taskExecution1);
 		if(i>0){
 			return new AjaxResult(AjaxResult.STATUS_OK, null, "撰写周报已结束");
 		}
 		return new AjaxResult(AjaxResult.STATUS_ERR, null, "操作失败！");
 	}
 	
 	/**
 	 * 跳转到上传环境搭建截图页面
 	 */
 	@RequestMapping(value="/toEnvironmentBuilding")
 	public String toEnvironmentBuilding(NewAssessment newAssessment){
 		newAssessment.setNewId(getMe().getId());
 		List<NewAssessment> newAssessmentList = newAssessmentService.findByModel(newAssessment);
 		WebUtil.getRequest().setAttribute("obj1", newAssessmentList.get(0));
 		return "admin/environment-building-form";
 	}
 	/**
 	 * 上传环境搭建截图
 	 */
 	@RequestMapping(value="/environmentBuilding")
 	public @ResponseBody AjaxResult environmentBuilding(NewAssessment newAssessment){
 		NewAssessment newAssessment1 = new NewAssessment();
 		newAssessment1.setNewId(getMe().getId());
 		List<NewAssessment> newAssessmentList = newAssessmentService.findByModel(newAssessment1);
 		newAssessment.setId(newAssessmentList.get(0).getId());
 		int i = newAssessmentService.modify(newAssessment);
 		if(i>0){
 			TaskExecution taskExecution = new TaskExecution();
 			taskExecution.setNewId(getMe().getId());
 	 		taskExecution.setTaskName("环境搭建");
 	 		//判断是否已经上传了截图
 	 		List<TaskExecution> taskExecutionList = currentService.findByModel(taskExecution);
 	 		if(taskExecutionList.size()<=0){
 	 			taskExecution.setStatus("1");
 	 			currentService.add(taskExecution);
 	 		}
 	 		return new AjaxResult(AjaxResult.STATUS_OK, null, "环境搭建截图上传成功");
 		}else{
 			return new AjaxResult(AjaxResult.STATUS_ERR, null, "环境搭建截图上传失败");
 		}
 		
 	}
 	
 	/**
 	 * 导师查看搭建环境截图
 	 */
 	@SaveRequestToken
   	@RequestMapping(value = "/editEnvironment")
	public String editEnvironment(Long id) {
 		NewAssessment newAssessment;
		if (id != null) {
			newAssessment = newAssessmentService.findById(id);
			WebUtil.getRequest().setAttribute("obj", newAssessment);
		}
		return "admin/environment-building-form";
	}
 	
 	/**
 	 * 导师结束环境搭建任务
 	 */
 	@RequestMapping(value="/endEnvironmentBuildingTask")
 	public @ResponseBody AjaxResult endEnvironmentBuildingTask(TaskExecution taskExecution){
 		taskExecution.setTaskName("环境搭建");
 		List<TaskExecution> taskExecutionList = currentService.findByModel(taskExecution);
 		if(taskExecutionList.size()<=0){
 			 return new AjaxResult(AjaxResult.STATUS_ERR, null, "学员还未开始本任务哦！");
 		}
 		if(taskExecutionList.get(0).getStatus().equals("2")){
 			return new AjaxResult(AjaxResult.STATUS_ERR, null, "学员已经完成本任务了哦~");
 		}
 		TaskExecution taskExecution1 = taskExecutionList.get(0);
 		taskExecution1.setStatus("2");
 		int i = currentService.modify(taskExecution1);
 		if(i>0){
 			return new AjaxResult(AjaxResult.STATUS_OK, null, "环境搭建已结束");
 		}
 		return new AjaxResult(AjaxResult.STATUS_ERR, null, "操作失败！");
 	}
 	
 	
 	/**
 	 * 新人开始框架解惑任务
 	 */
 	@RequestMapping(value="/startFrameDisabuse")
 	public @ResponseBody AjaxResult startFrameDisabuse(TaskExecution taskExecution){
 		taskExecution.setNewId(getMe().getId());
 		taskExecution.setStatus("1");
 		taskExecution.setTaskName("框架解惑");
 		List<TaskExecution> taskExecutionList = currentService.findByModel(taskExecution);
 		if(taskExecutionList.size()>0){
 			return new AjaxResult(AjaxResult.STATUS_ERR, null, "框架解惑已经开始啦~不要在点啦");
 		}
 		int i = currentService.add(taskExecution);
 		if(i>0){
 			return new AjaxResult(AjaxResult.STATUS_OK, null, "框架解惑已开始");
 		}
 		return new AjaxResult(AjaxResult.STATUS_ERR, null, "操作失败！");
 	}
 	
 	/**
 	 * 导师结束框架解惑任务
 	 */
 	@RequestMapping(value="/endFrameDisabuse")
 	public @ResponseBody AjaxResult endFrameDisabuse(TaskExecution taskExecution,Long key){
 		NewAssessment newAssessment = newAssessmentService.findById(key);
 		taskExecution.setNewId(newAssessment.getNewId());
 		taskExecution.setTaskName("框架解惑");
 		List<TaskExecution> taskExecutionList = currentService.findByModel(taskExecution);
 		if(taskExecutionList.size()<=0){
 			 return new AjaxResult(AjaxResult.STATUS_ERR, null, "学员还未开始本任务哦！");
 		}
 		if(taskExecutionList.get(0).getStatus().equals("2")){
 			return new AjaxResult(AjaxResult.STATUS_ERR, null, "学员已经完成本任务了哦~");
 		}
 		TaskExecution taskExecution1 = taskExecutionList.get(0);
 		taskExecution1.setStatus("2");
 		int i = currentService.modify(taskExecution1);
 		if(i>0){
 			return new AjaxResult(AjaxResult.STATUS_OK, null, "框架解惑已结束");
 		}
 		return new AjaxResult(AjaxResult.STATUS_ERR, null, "操作失败！");
 	}
 	
 	/**
 	 * 跳转到上传项目总结页面
 	 */
 	@RequestMapping(value="/toWorkPractice")
 	public String toWorkPractice(NewAssessment newAssessment){
 		newAssessment.setNewId(getMe().getId());
 		List<NewAssessment> newAssessmentList = newAssessmentService.findByModel(newAssessment);
 		WebUtil.getRequest().setAttribute("obj1", newAssessmentList.get(0));
 		return "admin/work-practice-form";
 	}
 	
 	/**
 	 * 上传项目总结
 	 */
 	@RequestMapping(value="/workPractice")
 	public @ResponseBody AjaxResult workPractice(NewAssessment newAssessment){
 		NewAssessment newAssessment1 = new NewAssessment();
 		newAssessment1.setNewId(getMe().getId());
 		List<NewAssessment> newAssessmentList = newAssessmentService.findByModel(newAssessment1);
 		newAssessment.setId(newAssessmentList.get(0).getId());
 		int i = newAssessmentService.modify(newAssessment);
 		if(i>0){
 			TaskExecution taskExecution = new TaskExecution();
 			taskExecution.setNewId(getMe().getId());
 	 		taskExecution.setTaskName("项目总结");
 	 		//判断是否已经上传了截图
 	 		List<TaskExecution> taskExecutionList = currentService.findByModel(taskExecution);
 	 		if(taskExecutionList.size()<=0){
 	 			taskExecution.setStatus("1");
 	 			currentService.add(taskExecution);
 	 		}
 			return new AjaxResult(AjaxResult.STATUS_OK, null, "项目总结上传成功");
 		}else{
 			return new AjaxResult(AjaxResult.STATUS_ERR, null, "项目总结上传失败");
 		}
 	}
 	
 	/**
 	 * 导师查看项目总结
 	 */
 	@SaveRequestToken
   	@RequestMapping(value = "/editWorkPractice")
	public String editWorkPractice(Long id) {
 		NewAssessment newAssessment;
		if (id != null) {
			newAssessment = newAssessmentService.findById(id);
			WebUtil.getRequest().setAttribute("obj", newAssessment);
		}
		return "admin/work-practice-form";
	}
 	
 	/**
 	 * 导师结束项目总结任务
 	 */
 	@RequestMapping(value="/endWorkPracticeTask")
 	public @ResponseBody AjaxResult endWorkPracticeTask(TaskExecution taskExecution){
 		taskExecution.setTaskName("项目总结");
 		List<TaskExecution> taskExecutionList = currentService.findByModel(taskExecution);
 		if(taskExecutionList.size()<=0){
 			 return new AjaxResult(AjaxResult.STATUS_ERR, null, "学员还未开始本任务哦！");
 		}
 		if(taskExecutionList.get(0).getStatus().equals("2")){
 			return new AjaxResult(AjaxResult.STATUS_ERR, null, "学员已经完成本任务了哦~");
 		}
 		TaskExecution taskExecution1 = taskExecutionList.get(0);
 		taskExecution1.setStatus("2");
 		int i = currentService.modify(taskExecution1);
 		if(i>0){
 			return new AjaxResult(AjaxResult.STATUS_OK, null, "项目总结已结束");
 		}
 		return new AjaxResult(AjaxResult.STATUS_ERR, null, "操作失败！");
 	}
 	
 	/**
 	 * 新人开始导师评分任务
 	 */
 	@RequestMapping(value="/startTutorScore")
 	public @ResponseBody AjaxResult startTutorScore(TaskExecution taskExecution){
 		taskExecution.setNewId(getMe().getId());
 		taskExecution.setStatus("1");
 		taskExecution.setTaskName("导师评分");
 		List<TaskExecution> taskExecutionList = currentService.findByModel(taskExecution);
 		if(taskExecutionList.size()>0){
 			return new AjaxResult(AjaxResult.STATUS_ERR, null, "导师评分已经开始啦~不要在点啦");
 		}
 		int i = currentService.add(taskExecution);
 		if(i>0){
 			return new AjaxResult(AjaxResult.STATUS_OK, null, "导师评分已开始");
 		}
 		return new AjaxResult(AjaxResult.STATUS_ERR, null, "操作失败！");
 	}
 	
 	/**
 	 * 导师评分
 	 */
 	@SaveRequestToken
   	@RequestMapping(value = "/editTutorScore")
	public String editTutorScore(Long id) {
 		NewAssessment newAssessment;
		if (id != null) {
			newAssessment = newAssessmentService.findById(id);
			WebUtil.getRequest().setAttribute("obj", newAssessment);
		}
		return "admin/tutor-score-form";
	}
 	
 	/**
	 *导师结束审核评价
	 */   
   	@RequestMapping(value = "/auditorAssess")
	public @ResponseBody AjaxResult auditorAssess(NewAssessment newAssessment) {
		//审核时间
   		newAssessment.setAuditorTime(new Date());
   		//综合素质得分
   		newAssessment.setZhszScores(newAssessment.getGtnl()+newAssessment.getJjnl()+newAssessment.getXxnl()+newAssessment.getCznl()+newAssessment.getZxnl());
   		//总分
   		newAssessment.setTotalScores(newAssessment.getKjsldScores()+newAssessment.getYmsjScores()+newAssessment.getDmgfScores()+newAssessment.getDmljScores()+newAssessment.getZhszScores());
   		int i = newAssessmentService.modify(newAssessment);
		if (i > 0) {
			TaskExecution taskExecution = new TaskExecution();
			taskExecution.setNewId(newAssessment.getNewId());
			taskExecution.setTaskName("导师评分");
			List<TaskExecution> taskExecutionList = currentService.findByModel(taskExecution);
			taskExecutionList.get(0).setStatus("2");
			int j = currentService.modify(taskExecutionList.get(0));
			if(j>0){
				return new AjaxResult(AjaxResult.STATUS_OK, null, "审核完成");
			}
		} 
			return new AjaxResult(AjaxResult.STATUS_ERR, null, "审核未完成");
   	}
   	
   	/**
 	 * 导师修改评价
 	 */
 	@SaveRequestToken
   	@RequestMapping(value = "/editModifyAssess")
	public String editModifyAssess(Long id) {
 		NewAssessment newAssessment;
		if (id != null) {
			newAssessment = newAssessmentService.findById(id);
			WebUtil.getRequest().setAttribute("obj", newAssessment);
		}
		return "admin/tutor-score-form";
	}
 	
 	/**
 	 * 学生查看导师评分
 	 */
 	@SaveRequestToken
   	@RequestMapping(value = "/selectTutorScore")
	public String selectTutorScore() {
 		NewAssessment newAssessment = new NewAssessment();
 		newAssessment.setNewId(getMe().getId());
		List<NewAssessment> newAssessmentList = newAssessmentService.findByModel(newAssessment);
		if(newAssessmentList.size()>0){
			WebUtil.getRequest().setAttribute("obj", newAssessmentList.get(0));
		}
		return "admin/tutor-scoreInfo-form";
	}
}